home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
cswsk10.zip
/
generic.frm
< prev
next >
Wrap
Text File
|
1995-07-01
|
6KB
|
220 lines
VERSION 2.00
Begin Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 1695
ClientTop = 2775
ClientWidth = 5610
Height = 3600
Left = 1635
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 5610
Top = 2430
Width = 5730
Begin Socket Socket2
Backlog = 1
Binary = -1 'True
Blocking = -1 'True
Broadcast = 0 'False
BufferSize = 0
HostAddress = ""
HostFile = ""
HostName = ""
Index = 0
InLine = 0 'False
Interval = 0
KeepAlive = 0 'False
Left = 720
Linger = 0
LocalPort = 0
LocalService = ""
Peek = 0 'False
Protocol = 0
RecvLen = 0
RemotePort = 0
RemoteService = ""
ReuseAddress = 0 'False
Route = -1 'True
SendLen = 0
TabIndex = 8
Timeout = 0
Top = 2520
Type = 1
Urgent = 0 'False
End
Begin Socket Socket1
Backlog = 1
Binary = -1 'True
Blocking = -1 'True
Broadcast = 0 'False
BufferSize = 0
HostAddress = ""
HostFile = ""
HostName = ""
InLine = 0 'False
Interval = 0
KeepAlive = 0 'False
Left = 120
Linger = 0
LocalPort = 0
LocalService = ""
Peek = 0 'False
Protocol = 0
RecvLen = 0
RemotePort = 0
RemoteService = ""
ReuseAddress = 0 'False
Route = -1 'True
SendLen = 0
TabIndex = 7
Timeout = 0
Top = 2520
Type = 1
Urgent = 0 'False
End
Begin CommandButton Command1
Caption = "&Connect"
Height = 375
Left = 2160
TabIndex = 6
Top = 2520
Width = 1215
End
Begin TextBox Text3
Enabled = 0 'False
Height = 855
Left = 960
TabIndex = 5
Top = 1320
Width = 3855
End
Begin TextBox Text2
Enabled = 0 'False
Height = 285
Left = 960
TabIndex = 3
Top = 840
Width = 3855
End
Begin TextBox Text1
Height = 285
Left = 960
TabIndex = 1
Top = 360
Width = 2055
End
Begin Label Label3
AutoSize = -1 'True
Caption = "Reply:"
Height = 195
Left = 360
TabIndex = 4
Top = 1320
Width = 555
End
Begin Label Label2
AutoSize = -1 'True
Caption = "Send:"
Height = 195
Left = 360
TabIndex = 2
Top = 840
Width = 510
End
Begin Label Label1
AutoSize = -1 'True
Caption = "Host:"
Height = 195
Left = 360
TabIndex = 0
Top = 360
Width = 465
End
End
Option Explicit
Dim LastSocket As Integer
Sub Command1_Click ()
Socket1.HostName = Trim$(Text1.Text)
Socket1.RemotePort = IPPORT_ECHO
Socket1.Action = SOCKET_CONNECT
End Sub
Sub Form_Load ()
Socket1.AddressFamily = AF_INET
Socket1.Protocol = IPPROTO_IP
Socket1.Type = SOCK_STREAM
Socket1.Binary = False
Socket1.BufferSize = 1024
Socket1.Blocking = False
Socket2(0).AddressFamily = AF_INET
Socket2(0).Protocol = IPPROTO_IP
Socket2(0).Type = SOCK_STREAM
Socket2(0).Blocking = False
Socket2(0).LocalPort = IPPORT_ECHO
Socket2(0).Action = SOCKET_LISTEN
LastSocket = 0
End Sub
Sub Form_Unload (Cancel As Integer)
Dim I As Integer
If Socket1.Connected Then Socket1.Action = SOCKET_CLOSE
If Socket2(0).Listening Then Socket2(0).Action = SOCKET_CLOSE
For I = 1 To LastSocket
If Socket2(I).Connected Then Socket2(I).Action = SOCKET_CLOSE
Next I
End
End Sub
Sub Socket1_Connect ()
Text2.Enabled = True
Text3.Enabled = True
End Sub
Sub Socket1_Read (DataLength As Integer, IsUrgent As Integer)
Socket1.RecvLen = DataLength
Text3.Text = Socket1.RecvData
End Sub
Sub Socket2_Accept (Index As Integer, SocketId As Integer)
Dim I As Integer
For I = 1 To LastSocket
If Not Socket2(I).Connected Then Exit For
Next I
If I > LastSocket Then
LastSocket = LastSocket + 1: I = LastSocket
Load Socket2(I)
End If
Socket2(I).AddressFamily = AF_INET
Socket2(I).Protocol = IPPROTO_IP
Socket2(I).Type = SOCK_STREAM
Socket2(I).Binary = True
Socket2(I).BufferSize = 1024
Socket2(I).Blocking = False
Socket2(I).Accept = SocketId
End Sub
Sub Socket2_Close (Index As Integer)
Socket2(Index).Action = SOCKET_CLOSE
End Sub
Sub Socket2_Read (Index As Integer, DataLength As Integer, IsUrgent As Integer)
Socket2(Index).RecvLen = DataLength
Socket2(Index).SendLen = DataLength
Socket2(Index).SendData = Socket2(Index).RecvData
End Sub
Sub Text2_KeyPress (KeyAscii As Integer)
If KeyAscii = 13 Then
Socket1.SendLen = Len(Text2.Text)
Socket1.SendData = Text2.Text
KeyAscii = 0: Text2.Text = ""
End If
End Sub